package com.newy.dao.sys;

import java.util.List;

import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.newy.core.hibernate.HibernateDao;
import com.newy.domain.sys.User;


@Repository
public class UserDao extends HibernateDao<User, Long> {	
	/**
	 * 删除用户（只是标记，没有直接删除）
	 */
	public void delete(User user){
		user.setIsDeleted(true);
		this.save(user);
	}
	
	public User findUserByLoginName(String loginName){
		return this.findUnique(Restrictions.eq("loginName", loginName), Restrictions.eq("isDeleted", false));
	}
	
	public List<User> findAllUsersOfDepart(Long departId){
		return find(Restrictions.eq("departId", departId), Restrictions.eq("isDeleted", false));
	}
}
